package top.vains.controller;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.vains.dto.UserRoleDto;
import top.vains.entity.Result;
import top.vains.service.IUserRoleService;
import top.vains.util.ResultUtils;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author vains
 * @since 2020-02-17
 */
@RestController
@RequestMapping("/userRole")
@Api(tags = "用户角色接口，更新指定用户对应的角色")
public class UserRoleController {

    private final IUserRoleService userRoleService;

    @Autowired
    public UserRoleController(IUserRoleService userRoleService) {
        this.userRoleService = userRoleService;
    }

    @PutMapping("/updateUserRole")
    @ApiOperation(value = "更新用户已拥有的角色", notes = "更新用户已拥有的角色")
    public Result updateUserRole(@RequestBody UserRoleDto userRoleDto) {
        userRoleService.updateUserRole(userRoleDto);
        return ResultUtils.success("更新成功！");
    }

}
